package wu2020.top.spring.boot.flyway.simple.controller;

import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import com.wu.framework.inner.layer.web.EasyController;
import org.springframework.web.bind.annotation.*;
import com.wu.framework.response.Result;
import com.wu.framework.response.ResultFactory;
import org.springframework.beans.factory.annotation.Autowired;
import jakarta.annotation.Resource;
import wu2020.top.spring.boot.flyway.simple.domain.model.person.Person;
import wu2020.top.spring.boot.flyway.simple.application.command.person.PersonRemoveCommand;
import wu2020.top.spring.boot.flyway.simple.application.command.person.PersonStoryCommand;
import wu2020.top.spring.boot.flyway.simple.application.command.person.PersonUpdateCommand;
import wu2020.top.spring.boot.flyway.simple.application.command.person.PersonQueryListCommand;
import wu2020.top.spring.boot.flyway.simple.application.command.person.PersonQueryOneCommand;
import wu2020.top.spring.boot.flyway.simple.application.PersonApplication;
import wu2020.top.spring.boot.flyway.simple.application.dto.PersonDTO;
import java.util.List;
import com.wu.framework.inner.lazy.database.expand.database.persistence.domain.LazyPage;
/**
 * describe person 
 *
 * @author Jia wei Wu
 * @date 2024/03/07 09:59 上午
 * @see com.wu.framework.inner.lazy.persistence.reverse.lazy.ddd.DefaultDDDLazyController 
 **/
@Tag(name = "提供者")
@EasyController("/person")
public class PersonProvider  {

    @Resource
    private PersonApplication personApplication;

    /**
     * describe 新增
     *
     * @param personStoryCommand 新增     
     * @return {@link Result<Person>} 新增后领域对象     
     
     * @author Jia wei Wu
     * @date 2024/03/07 09:59 上午
     **/

    @Operation(summary = "新增")
    @PostMapping("/story")
    public Result<Person> story(@RequestBody PersonStoryCommand personStoryCommand){
        return personApplication.story(personStoryCommand);
    }
    /**
     * describe 批量新增
     *
     * @param personStoryCommandList 批量新增     
     * @return {@link Result<List<Person>>} 新增后领域对象集合     
     
     * @author Jia wei Wu
     * @date 2024/03/07 09:59 上午
     **/

    @Operation(summary = "批量新增")
    @PostMapping("/batchStory")
    public Result<List<Person>> batchStory(@RequestBody List<PersonStoryCommand> personStoryCommandList){
        return personApplication.batchStory(personStoryCommandList);
    }
    /**
     * describe 更新
     *
     * @param personUpdateCommand 更新     
     * @return {@link Result<Person>} 领域对象     
     
     * @author Jia wei Wu
     * @date 2024/03/07 09:59 上午
     **/

    @Operation(summary = "更新")
    @PutMapping("/updateOne")
    public Result<Person> updateOne(@RequestBody PersonUpdateCommand personUpdateCommand){
        return personApplication.updateOne(personUpdateCommand);
    }
    /**
     * describe 查询单个
     *
     * @param personQueryOneCommand 查询单个     
     * @return {@link Result<PersonDTO>} DTO对象     
     
     * @author Jia wei Wu
     * @date 2024/03/07 09:59 上午
     **/

    @Operation(summary = "查询单个")
    @GetMapping("/findOne")
    public Result<PersonDTO> findOne(@ModelAttribute PersonQueryOneCommand personQueryOneCommand){
        return personApplication.findOne(personQueryOneCommand);
    }
    /**
     * describe 查询多个
     *
     * @param personQueryListCommand 查询多个     
     * @return {@link Result<List<PersonDTO>>} DTO对象     
     
     * @author Jia wei Wu
     * @date 2024/03/07 09:59 上午
     **/

    @Operation(summary = "查询多个")
    @GetMapping("/findList")
    public Result<List<PersonDTO>> findList(@ModelAttribute PersonQueryListCommand personQueryListCommand){
        return personApplication.findList(personQueryListCommand);
    }
    /**
     * describe 分页查询多个
     *
     * @param personQueryListCommand 分页查询多个     
     * @return {@link Result<LazyPage<PersonDTO>>} 分页DTO对象     
     
     * @author Jia wei Wu
     * @date 2024/03/07 09:59 上午
     **/

    @Operation(summary = "分页查询多个")
    @GetMapping("/findPage")
    public Result<LazyPage<PersonDTO>> findPage(@Parameter(description ="分页大小") @RequestParam(defaultValue = "10", value = "size") int size,
                           @Parameter(description ="当前页数") @RequestParam(defaultValue = "1", value = "current") int current,@ModelAttribute PersonQueryListCommand personQueryListCommand){
        return personApplication.findPage(size,current,personQueryListCommand);
    }
    /**
     * describe 删除
     *
     * @param personRemoveCommand 删除     
     * @return {@link Result<Person>}      
     
     * @author Jia wei Wu
     * @date 2024/03/07 09:59 上午
     **/

    @Operation(summary = "删除")
    @DeleteMapping("/remove")
    public Result<Person> remove(@ModelAttribute PersonRemoveCommand personRemoveCommand){
        return personApplication.remove(personRemoveCommand);
    }
}